package com.jse;

import java.nio.charset.Charset;
import java.util.Date;

import org.nutz.integration.quartz.NutQuartzCronJobFactory;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.lang.Encoding;
import org.nutz.lang.Times;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.NutConfig;

/**
 * Created by wizzer on 2016/6/21.
 */
public class Setup implements org.nutz.mvc.Setup {
	private static final Log log = Logs.get();

	public void init(NutConfig config) {
		try {
			// 环境检查
			if (!Charset.defaultCharset().name().equalsIgnoreCase(Encoding.UTF8)) {
				log.warn("This project must run in UTF-8, pls add -Dfile.encoding=UTF-8 to JAVA_OPTS");
			}
			log.infof("%s welcome! jse init success!", Times.format("YYYY-MM-dd HH:mm:ss", new Date()));
		} catch (Exception e) {
			e.printStackTrace();
		}
		NutIoc ioc = (NutIoc) config.getIoc();

		PropertiesProxy prop = ioc.get(PropertiesProxy.class, "conf");

		if (prop.getBoolean("quartz.enable"))
			ioc.get(NutQuartzCronJobFactory.class);

	}

	public void destroy(NutConfig config) {

	}

}
